package com.common.utils;

import com.business.web.spring.BatchController;
import com.common.db.JsonVO;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class WebExceptionController {

    private static org.apache.log4j.Logger log = Logger.getLogger(WebExceptionController.class.getName());

//    @ExceptionHandler
//    public ResultBean unknownAccount(UnknownAccountException e) {
//        log.error("账号不存在", e);
//        return ResultBean.error(1, "账号不存在");
//    }
//
//    @ExceptionHandler
//    public ResultBean incorrectCredentials(IncorrectCredentialsException e) {
//        log.error("密码错误", e);
//        return ResultBean.error(-2, "密码错误");
//    }

    @ExceptionHandler
    public JsonVO unknownException(Exception e) {
        JsonVO vo = new JsonVO();
        vo.setResult("error");
        vo.setJieguo(false);

        log.error("******发生了未知异常=", e);
        log.error("******系统出现错误, 请联系网站管理员!=", e);
        // 发送邮件通知技术人员.
        //(-99, "系统出现错误, 请联系网站管理员!");
        vo.setInfo(e.toString());
        return vo ;
    }

}
